<?php
	include_once 'autoload.php';
	

	session_start();

	$ctl = new ChPassCtl();
	$ctl->checkAdmin();
	$ctl->checkNotReadonly();
	$ctl->proceed();
	
	$header = new Header();
	$header->render('Change User Password (admin only)');

	$form = $ctl->getChPassForm();

	$id = $form->getId();
	$name = $form->getName();
	$login = $form->getLogin();
	
	$pass = $form->getPass();
	$repeat = $form->getRepeat();
	
	$readonly = $form->isReadonly();
	
	$title = "{$name} ({$login})";
	$title = htmlspecialchars($title);
	
	$checkbox = HtmlUtil::getCheckbox('readonly', 'on', $readonly, array());
	
?>
<form method="post">
<input type="hidden" name="pagename" value="chpass" id="pgid">
<input type="hidden" name="metname" value="" id="metid">

<input type="hidden" name="id" value="<?php echo $id; ?>">
<input type="hidden" name="name" value="<?php echo $name; ?>">
<input type="hidden" name="login" value="<?php echo $login; ?>">

<h2>Change User Password</h2>
<p>Please provide the new credentials for the user, then click submit</p>

<table cellpadding="4" cellspacing="0" class="list">
	<tr>
		<td nowrap>User:</td>
		<td nowrap><?php echo $title; ?></td>
	</tr>
	<tr>
		<td nowrap>New Password:</td>
		<td nowrap><input type="password" name="pass" value="<?php echo $pass?>"></td>
	</tr>
	<tr>
		<td nowrap>Repeat:</td>
		<td nowrap><input type="password" name="repeat" value="<?php echo $repeat; ?>"></td>
	</tr>
	<tr>
		<td nowrap>&nbsp;</td>
		<td nowrap><?php echo $checkbox; ?> Readonly</td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td>
			<input type="button" value="Submit" onclick="triggerform('submit');" class="enter">
			<input type="button" value="Cancel" onclick="triggerform('cancel');" class="escape">
		</td>
	</tr>
</table>
</form>
<?php
	$footer = new Footer();
	$footer->render();
?>
